package com.example.demo.dao;

import com.example.demo.domain.Department;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository("departmentDao")
public class DepartmentDao {
    private List<Department> departmentList = new ArrayList<Department>();
    //增加
    public List<Department> addDepartment (Department department){
        departmentList.add(department);
    return departmentList;
    }
    //批量增加
    public List<Department> addDepartments(List<Department> departments){
        departmentList.addAll(departments);
        return departmentList;
    }
    //查询
    public List<Department> getAll(){
        return departmentList;
    }
    public Department getOneByNo(String no){
        Department department = null;
        if(departmentList.size()==0){
            return null;
        }else {
            for(int i = 0;i<departmentList.size();i++){
                if(departmentList.get(i).getNo().equals(no)){
                    department=departmentList.get(i);
                    break;
                }
            }
        }
        return department;
    }
//    //更新
//    public boolean updateDepartment(Department department){
//        boolean flag = false;
//        if(departmentList.size()!=0){
//
//        }
//    }
}
